package org.hhchat.leetcode.tree;

import org.hhchat.leetcode.dataStruct.TreeNode;

/**
 * Created this one by HMH on 2017/10/3.
 */
public class code538_easy {

    static class Solution {
        public TreeNode convertBST(TreeNode root) {
            visit(root);
            return root;
        }

        int sum = 0;

        public void visit(TreeNode root) {
            if (root == null) {
                return;
            }
            visit(root.right);
            int temp = root.val;
            root.val += sum;
            sum += temp;
            visit(root.left);

        }
    }
    public static void main(String[] args){

    }
}
